package com.xbongbong.saas.model.impl;/*/*/

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.saas.domain.dao.CabinetFileDao;
import com.xbongbong.saas.domain.entity.CabinetFileEntity;
import com.xbongbong.saas.model.CabinetFileModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
 *
 * @author 魏荣杰
 * @date 2019/6/20 15:40
 * @since v1.0
 * @version v1.0
 */
@Service("cabinetFileModel")
public class CabinetFileModelImpl implements CabinetFileModel {
    @Resource
    private CabinetFileDao cabinetFileDao;

    @Override
    public Integer insert(CabinetFileEntity entity) throws XbbException {
        Long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        return cabinetFileDao.insert(entity);
    }

    @Override
    public Integer update(CabinetFileEntity entity) throws XbbException {
        return cabinetFileDao.update(entity);
    }

    @Override
    public List<CabinetFileEntity> findEntitys(Map<String, Object> param) {
        return cabinetFileDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return cabinetFileDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer deleteByKey(Long key, String corpid) {
        return cabinetFileDao.deleteByKey(key, corpid);
    }

    @Override
    public CabinetFileEntity getByKey(Long key, String corpid) {
        return cabinetFileDao.getByKey(key, corpid);
    }

    @Override
    public void insertBatch(List<CabinetFileEntity> cabinetFileEntityList) {
        cabinetFileDao.insertBatch(cabinetFileEntityList);
    }

    @Override
    public List<CabinetFileEntity> getCabinetFiles(String corpid, Long dataId, Integer businessType, Integer type, Long refId) {
        return cabinetFileDao.getCabinetFiles(corpid, dataId, businessType, type, refId);
    }

    @Override
    public List<CabinetFileEntity> getCabinetFilesByUserId(String corpid, String userId, Integer businessType) {
        return cabinetFileDao.getCabinetFilesByUserId(corpid, userId, businessType);
    }

    @Override
    public Long getAllSizeByCorpid(String corpid){
        return cabinetFileDao.getAllSizeByCorpid(corpid);
    }

    @Override
    public Integer deleteBatch(List<Long> idIn, String corpid) {
        return cabinetFileDao.deleteBatch(idIn, corpid);
    }

    @Override
    public List<CabinetFileEntity> getCabinetFilesByIdIn(String corpid, List<Long> dataIdIn, Integer businessType) {
        return cabinetFileDao.getCabinetFilesByIdIn(corpid, dataIdIn, businessType);
    }

    @Override
    public List<Long> getCabinetFileIdsByIdIn(String corpid, List<Long> dataIdIn, Integer businessType) {
        return cabinetFileDao.getCabinetFileIdsByIdIn(corpid, dataIdIn, businessType);
    }

    @Override
    public void updateBatch(List<CabinetFileEntity> cabinetFileEntities, String corpid) {
        cabinetFileDao.updateBatch(cabinetFileEntities, corpid);
    }

    /**
     * 批量插入文件柜照片，用于资金三期脚本迁移
     *
     * @param cabinetFileModelEntitys
     * @return
     */
    @Override
    public int insertBatchAll(List<CabinetFileEntity> cabinetFileModelEntitys) {
        return cabinetFileDao.insertBatchAll(cabinetFileModelEntitys);
    }
}
